<template>
	<view>
		<scroll-view scroll-x class="bg-white nav tab-view" >
			<view class="flex text-center">
				<view class="flex-sub cu-item " :class="status == 1 ? 'text-blue cur':''" data-status="1"  @click.stop.prevent="tabSelect">
					待审核
				</view>
				<view class="flex-sub cu-item" :class="status == 2 ? 'text-blue cur':''" data-status="2"  @click.stop.prevent="tabSelect">
					审核通过
				</view>
				<view class="flex-sub cu-item" :class="status == 3 ? 'text-blue cur':''" data-status="3"  @click.stop.prevent="tabSelect">
					不通过
				</view>
			</view>
		</scroll-view>
		<view style="height: 60px;"></view>
		<view class="cu-list menu-avatar" >
			<view class="cu-item" style="height: 60px;" v-for="(item,index) in listData" :key="index">
				<view class="cu-avatar radius lg" style="border-radius: 25px;" :style="'background-image: url('+item.avatarUrl+')'"></view>
				<view class="content">
					<view class="">
						<view class="text-cut">{{ item.nickName }}</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="text-cut">{{ item.regTime }}</view>
					</view>
				</view>
				<view class="action">
					<view class="text-grey text-xs " style="margin-left: -50px;" v-if="item.status == 1">口令:{{item.word}}</view>
					<view class="text-grey text-xs " style="margin-left: -50px;" v-if="item.status == 2">审核通过</view>
					<view class="text-grey text-xs " style="margin-left: -50px;" v-if="item.status == 3">{{item.word}}</view>
					<view class="cu-tag round bg-blue sm" 
					style="margin-left: -55px;height: 20px;" 
					v-if="item.status == 1 || item.status == 3"
					@click="apprevo" data-status="2" :data-id="item.id">
						<text>通过</text>
					</view>
					<view class="cu-tag round bg-red sm" 
					style="height: 20px;"
					v-if="item.status == 1 || item.status == 3"
					@click="apprevo" data-status="3" :data-id="item.id">
						<text>不通过</text>
					</view>
				</view>
			</view>
			<!--加载loadding-->
			<tui-loadmore :visible="loadding"></tui-loadmore>
			<tui-nomore :visible="!pullUpOnLast" bgcolor="#ffffff"></tui-nomore>
			<!--加载loadding-->
		</view>
	</view>
</template>

<script>
import tuiLoading from '../../../components/loading/loading';
import tuiLoadmore from '../../../components/loadmore/loadmore';
import tuiNomore from '../../../components/nomore/nomore';

const http = require('../../../utils/http.js');

export default {
    components: {
        tuiLoading,
        tuiLoadmore,
        tuiNomore
    },
    data() {
        return {
			status:1,
            loadding: false,
            listData: [],
            pullUpOnLast: true,
        };
    },
    onLoad: function (options) {
		this.apprevoList(true);
    },
    onPullDownRefresh: function () {
	},
    onReachBottom: function () {
        if (!this.pullUpOnLast) {
            return;
        }
		this.apprevoList(false);
    },
    methods: {
		tabSelect: function (e) {
		    let status = e.currentTarget.dataset.status;
		    if (this.status == status) {
		        return false;
		    }
		    this.setData({
		        status: status,
				pageNum: 1,
				listData:[]
		    });
			
			this.apprevoList(true);
		},
        apprevoList: function (refresh) {
            let that = this;
            that.setData({
                loadding: true
            });
            let offset = 0;

            if (!refresh) {
                offset = that.listData.length;
            }
			uni.showLoading({
				title:'加载中'
			})
            var params = {
                url: '/talent/apprevoList',
                method: 'GET',
                data: {
                    offset: offset,
					status:that.status
                },
                callBack: function (res) {
					if(res.code == 200){
						that.setData({
						    loadding: false,
						    listData: refresh ? res.data.list : that.listData.concat(res.data.list),
						    pullUpOnLast: !res.data.isLastPage ? true : false
						});
					}else{
						that.setData({
						    loadding: false,
							pullUpOnLast:false
						});
					}
					uni.hideLoading()
                }
            };
            http.request(params);
        },
		apprevo:function(e){
			let that = this;
			let status = e.currentTarget.dataset.status;
			let id = e.currentTarget.dataset.id;
			uni.showLoading({
				title:'处理中'
			})
			var params = {
			    url: '/talent/apprevo',
			    method: 'GET',
			    data: {
					status:status,
					id:id
			    },
			    callBack: function (res) {
					if(res.code == 200){
						uni.showToast({
							title:'处理成功',
							icon:'none',
							success() {
								
							}
						})
						setTimeout(function(){
							that.apprevoList(true)
						},1500);
					}else{
						uni.showToast({
							title:'处理失败',
							icon:'none'
						})
					}
			    }
			};
			http.request(params);
		}
		
    }
};
</script>


<style>
@import './approve.css';
</style>
